﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Webdiyer.WebControls.Mvc;

namespace mvcDemo.Controllers
{
    public class UserController : Controller
    {
        //
        // GET: /User/

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Login()
        {            
            return View();
        }
        [HttpPost]
        public ActionResult Login(Models.LoginModelNew loginModel)
        {
            if (loginModel.UserName == "张三" && loginModel.Password == "123456")
                Response.Write("正确！");
            else
                Response.Write("不正确！");
            return View();
        }
        public ActionResult User()
        {
            Models.UserModel userModel = new Models.UserModel();
            userModel.UserName = "wxf";
            userModel.Password = "123";
            userModel.Sex = 0;
            userModel.Age = 30;
            userModel.Height = 170;
            userModel.Weight = 70;
            userModel.Graduated = "毕业院校";
            return View(userModel);
        }
        [HttpPost]//User
        public ActionResult User(Models.UserModel userModel)
        {
            Response.Write(userModel.UserName);
            Response.Write("<br />");
            Response.Write(userModel.Password);
            Response.Write("<br />");
            Response.Write(userModel.Sex);
            Response.Write("<br />");
            Response.Write(userModel.Age);
            Response.Write("<br />");
            Response.Write(userModel.Height);
            Response.Write("<br />");
            Response.Write(userModel.Weight);
            Response.Write("<br />");
            Response.Write(userModel.Graduated);
            Response.Write("<br />");
            return View();
        }
        public ActionResult Validation()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Validation(Models.ValidationModel model)
        {
            if (ModelState.IsValid)
            {
                var inputNumber = model.InputNumber;
            }
            return View();
        }

     
        //获取列表
        //可为空
        //public ActionResult List(int? id = 1)
        //{
        //    List<Models.UserModel> userList = new List<Models.UserModel>();
        //    int totalCount = 0;
        //    int pageIndex = id ?? 1;
        //    userList = GetList("", 2, (pageIndex - 1) * 2, out totalCount);
        //    PagedList<Models.UserModel> mPage = userList.AsQueryable().ToPagedList(pageIndex, 2);
        //    mPage.TotalItemCount = totalCount;
        //    mPage.CurrentPageIndex = (int)(id ?? 1);
        //    return View(mPage);
        //}     
    }
}
